Repository navigation
GLM prefix restore: a refused restore's release keeps the assistant charge on its stage - #471
Merged
Merged
Conversation
A request admitted under a first-token deadline prepares its GLM complete-prefix restore, including the MTP assistant binding, before publication. Until the import commits, the checkpoint stage holds that binding's charge. When publication is refused, the request's release retired the binding as if the request held the charge and added it to the ledger as growth; a ledger with no headroom refused that growth and the release trapped. Retiring a binding whose import has not committed now only deactivates it. The stage keeps the charge and refunds it when the restore's native work retires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… growth check The regression requires the capacityExhausted rejection, waits for the retirement and a quiescent shutdown, then requires that no growth followed the refusal. The engine helper defaults its process owner; comments are shorter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
A GLM-5.3-Flash request submitted with a first-token deadline prepares its complete-prefix restore before publication, including the MTP assistant binding that
CBv2GLM5NextPreparedAssistantissues from the import proof. Until that import commits, the checkpoint stage holds the binding's charge (mtpPrepaidis part of the stage's auxiliary bytes);transferCheckpointStagemoves it into the request only on a successful commit.When publication is refused (for example, the process ledger refuses the transfer's growth),
applyAdoptionreturnsfalseand the deadline path callsdiscardDeadlineRejectedRequest, which callsAdmissionV2.releaseAll(id:). The request holds no tokens, but its binding still exists and its assistant state still holds MTP leases, soretireMTPBindingLockedreturnedresolved.bytes(forTokens: 0), a nonzero fixed MTP charge, as retained bytes.releaseAllLockedadded those bytes toledgerBytes, which makes the release a growth.publishProcessReductionLockedassumes a release never grows, so a ledger with no headroom refused it andpreconditionFailure("process charge retirement refused")trapped. The prepared assistant abandons the binding only later, after the restore's native work is fenced on the engine queue, so the release always runs first.Change:
retireMTPBindingLockednow retires a binding whose import has not committed by deactivating its context only (retireStageFunded()), with zero retained bytes. The stage keeps the charge and refunds it when the native work retires. This coversreleaseAll,unreserveto zero anddetachReservation. Committed imports and ordinary bindings release as before.Before
flowchart TD A[Deadline admission prepares GLM prefix restore] --> B[Imported MTP binding, stage-funded, leases live] B --> C[Publication refused] C --> D[discardDeadlineRejectedRequest] D --> E[releaseAll: retire binding with reservedTokens 0] E --> F[Ledger grows by the fixed MTP charge] F --> G{Process ledger has headroom?} G -- yes --> H[Charged twice until leases die] G -- no --> I[preconditionFailure: trap]After
Tests
GLM5NextCompleteCheckpointTests.refusedNativeMTPPrefixAdoptionReleasesWithoutChargeGrowth(real tiny GLM target and MTP assistant, real paged pool, admission and complete-prefix store): a producer engine donates the checkpoint; the consumer stages it and submits under a first-token deadline. Once the restore is prepared, its process owner refuses the next growth, as a ledger under memory pressure would. The test requires that the request is not admitted and not adopted, that exactly one growth was refused, that no growth follows the refusal, that the charge drains back to its pre-stage baseline, and that there is no native completion fault.nativeMTPProfilesResumeFromCompletePrefixExactlynow builds its engines through the sharednativeMTPEngine(store:process:verification:)helper (same configuration and checks).2b7021a9; red controlc128a264.2b7021a9: run 44788822386, all 12 shards green; the new test passes in shard 9.c128a264: run 44788833159, shard 9 fails only ongate.growthAfterRefusal.isEmpty([7859348]: the fixed MTP charge grew after the refusal).Validation
swift-format(Xcode 27.2) format and lint: clean on the changed files.capacityExhaustedrejection, waits for retirement and a quiescent shutdown, then checks that no growth followed the refusal.Checklist
swift-formaton the changed fileschangelog.d/glm-refused-prefix-restore-release.mdAI usage
accurately describes the code changes.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Merge note (2026-11-20): merged after CI green on this head
2b7021a9(run 44788822386) and the red control #472. Providerdevpins the same four files onsdk/provider-0.10.16-glm-release-fix(995f3a5e) in Layr-Labs/d-inference#2436. The attestation box above is left for the owner.